package com.demo.taghandler;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

public class MyForEachHandler extends SimpleTagSupport {
	
	private int begin;
	private int end;
	private int step;
	private String var;
	
	public String getVar() {
		return var;
	}
	public void setVar(String var) {
		this.var = var;
	}
	public int getBegin() {
		return begin;
	}
	public void setBegin(int begin) {
		this.begin = begin;
	}
	public int getEnd() {
		return end;
	}
	public void setEnd(int end) {
		this.end = end;
	}
	public int getStep() {
		return step;
	}
	public void setStep(int step) {
		this.step = step;
	}

	
	@Override
	public void doTag() throws JspException, IOException {
		
		 for (int i = getBegin(); i <= getEnd(); i=i+getStep()) {
				
			 getJspContext().setAttribute("result", i);
			 getJspBody().invoke(null); //execute body and write on response
						 
		}
	}

}
